package cn.bugstack.config;


import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class GuavaConfig {

    @Bean(name="weixinAccessToken")
    public Cache<String,String> weixinAccessToken() {
        return CacheBuilder.newBuilder().expireAfterWrite(2, TimeUnit.HOURS).build();
    }

    @Bean(name="openidToken")
    public Cache<String,String> openidToken() {
        return CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build();
    }
}
